package com.productclass;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.dao.CategroryDao;
import com.vo.Category;

public class ProductClass_modify_servlet_modify extends HttpServlet {

	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html,utf-8");
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		int parentId = 0,a =0;
		String name = null;
		CategroryDao dao = new CategroryDao();
		parentId = Integer.parseInt(request.getParameter("parentId"));
		name = request.getParameter("className");
		Category category = new  Category();
		category.setEpc_name(name);
		
		if(parentId != 0){
			try {
				
				 a  = dao.updateProductClass(parentId, category);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}else{
			System.out.println("error"+"!!!!");
		}
		if(a > 0){
			response.sendRedirect("productClassServlet_s");
		}else{
			System.out.println("no");
		}
		
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		try {
			doGet(request, response);
		} catch (Exception e) {
			// TODO: handle exception
		}
		
		
	}

}
